<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/templates/tmpl_admin.xhtml">
	<ui:define name="centro">

		<h:form id="form">
			<p:dataTable id="listaJogador" var="jogador"
				value="#{jogadorMBean.jogadores}" paginator="true" rows="10"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				rowsPerPageTemplate="5,10,15"
				emptyMessage="Nenhum jogador cadastrado"
				filteredValue="#{jogadorMBean.jogadoresFiltro}"
				resizableColumns="true" selectionMode="single"
				rowKey="#{jogador.email}" selection="#{jogadorMBean.jogador}">

				<p:ajax event="rowSelect" update=":form:formulario"
					oncomplete="jogadorDialog.show()" listener="#{jogadorMBean.editar}" />

				<f:facet name="header">
					Lista de Papéis
				</f:facet>

				<p:column headerText="E-mail" sortBy="#{jogador.email}"
					filterBy="#{jogador.email}" filterMatchMode="contains">
					<p:outputLabel value="#{jogador.email}" />
				</p:column>

				<p:column headerText="Nome" sortBy="#{jogador.nome}"
					filterBy="#{jogador.nome}" filterMatchMode="contains">
					<p:outputLabel value="#{jogador.nome}" />
				</p:column>

				<p:column headerText="Nível">
					<p:outputLabel value="#{jogador.nivel.descricao}" />
				</p:column>

				<p:column headerText="Papel">
					<p:outputLabel value="#{jogador.papel.descricao}" />
				</p:column>

				<p:column headerText="Scrums">
					<p:outputLabel value="#{jogador.scrums}" />
				</p:column>

				<p:column headerText="Experiência">
					<p:outputLabel value="#{jogador.experiencia}" />
				</p:column>

				<p:column headerText="Dia Início">
					<p:outputLabel value="#{jogador.diaInicio.dia}" />
				</p:column>

				<p:column headerText="Acesso">
					<p:outputLabel value="#{jogador.acesso}" />
				</p:column>

				<p:column headerText="Ativo">
					<p:outputLabel value="#{jogador.ativo}" />
				</p:column>

			</p:dataTable>

			<p:dialog header="Jogador" widgetVar="jogadorDialog"
				resizable="false" showEffect="clip" hideEffect="fold">

				<h:panelGrid id="formulario" columns="1" cellpadding="4">

					<p:graphicImage value="/temp/#{perfilMBean.usuario.email}.jpg"
						width="100px" height="150px" />

					<h:panelGrid id="formulario" columns="2" cellpadding="4">

						<p:outputLabel value="Nome:" />
						<p:outputLabel value="#{jogadorMBean.jogador.nome}" />

						<p:outputLabel value="Ativo" />
						<p:selectBooleanCheckbox validator="#{jogadorMBean.jogador.ativo}" />

					</h:panelGrid>

					<p:commandButton action="#{jogadorMBean.salvar}" value="Salvar"
						update=":form:listaJogador" oncomplete="jogadorDialog.hide()" />

				</h:panelGrid>
			</p:dialog>

		</h:form>

	</ui:define>
</ui:composition>

</html>
